﻿using System;
using Avivo.Tools.Sprite.Views;
using Microsoft.Expression.Framework;
using Microsoft.Expression.Framework.Commands;

namespace Sprite.Blend.AddIn
{
	public class SpriteAddIn : CommandTarget, IPackage
	{
		private IApplicationService appService;
		private SpriteView view;

		public void Initialize()
		{
			var contractService = new SpriteContractService(appService);

			this.view = new SpriteView();
			this.view.ViewModel.RegisterContractService(contractService);

			appService.CommandService.AddTarget(this);

			if (appService.WindowService.PaletteRegistry["xsprite"] == null)
			{
				appService.WindowService.RegisterPalette("xsprite", this.view, "Sprite Generator");
			}
		}

		public void Load(IApplicationService applicationService)
		{
			appService = applicationService;
			Initialize();
		}

		public void Unload()
		{
		}
	}
}